<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>设计模式 - 概述 | 爪哇干货分享</title>
    <meta name="generator" content="VuePress 1.9.7">
    <link rel="icon" href="/favicon.ico">
    <script charset="utf-8" async="async" src="/js/jquery.min.js"></script>
    <script charset="utf-8" async="async" src="/js/global.js"></script>
    <script charset="utf-8" async="async" src="/js/fingerprint2.min.js"></script>
    <script charset="utf-8" async="async" src="https://s9.cnzz.com/z_stat.php?id=1278232949&amp;web_id=1278232949"></script>
    <script>
              var _hmt = _hmt || [];
              (function() {
                var hm = document.createElement("script");
                hm.src = "https://hm.baidu.com/hm.js?e68b39347be2339192f80082c317901e";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(hm, s);
              })();
            </script>
    <meta name="description" content="包含: Java 基础，面试小册，Spring源码解析，中间件原理">
    <meta property="article:modified_time" content="2022-03-30T11:44:00.000Z">
    <meta property="og:title" content="设计模式 - 概述">
    <meta property="og:type" content="article">
    <meta property="og:url" content="/md/dev-spec/pattern/1_overview.html">
    <meta name="twitter:title" content="设计模式 - 概述">
    <meta name="twitter:url" content="/md/dev-spec/pattern/1_overview.html">
    <meta name="twitter:card" content="summary_large_image">
    <meta name="robots" content="all">
    <meta name="author" content="janker">
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">
    <meta name="keywords" content="爪哇干货分享,  中间件, Spring, Java基础, 面试小册">
    <meta name="apple-mobile-web-app-capable" content="yes">
    
    <link rel="preload" href="/assets/css/0.styles.b854e512.css" as="style"><link rel="preload" href="/assets/css/styles.css?v=1648640762568" as="style"><link rel="preload" href="/assets/js/cg-styles.js?v=1648640762568" as="script"><link rel="preload" href="/assets/js/cg-app.js?v=1648640762568" as="script"><link rel="preload" href="/assets/js/cg-4.js?v=1648640762568" as="script"><link rel="preload" href="/assets/js/cg-3.js?v=1648640762568" as="script"><link rel="preload" href="/assets/js/cg-18.js?v=1648640762568" as="script"><link rel="preload" href="/assets/js/cg-5.js?v=1648640762568" as="script"><link rel="preload" href="/assets/js/cg-6.js?v=1648640762568" as="script">
    <link rel="stylesheet" href="/assets/css/0.styles.b854e512.css"><link rel="stylesheet" href="/assets/css/styles.css?v=1648640762568">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">爪哇干货分享</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/md/other/guide-to-reading.html" class="nav-link">
  导读
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Java" class="dropdown-title"><span class="title">Java</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/md/java/interview/book.html" class="nav-link">
  面经手册
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="方法" class="dropdown-title"><span class="title">方法</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/md/dev-spec/pattern/1_overview.html" aria-current="page" class="nav-link router-link-exact-active router-link-active">
  设计模式
</a></li></ul></div></div><div class="nav-item"><a href="/md/about/me/about-me.html" class="nav-link">
  关于
</a></div><div class="nav-item"><a href="https://github.com/janker0718/ShareJava" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Github
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/md/other/guide-to-reading.html" class="nav-link">
  导读
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="Java" class="dropdown-title"><span class="title">Java</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/md/java/interview/book.html" class="nav-link">
  面经手册
</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="方法" class="dropdown-title"><span class="title">方法</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/md/dev-spec/pattern/1_overview.html" aria-current="page" class="nav-link router-link-exact-active router-link-active">
  设计模式
</a></li></ul></div></div><div class="nav-item"><a href="/md/about/me/about-me.html" class="nav-link">
  关于
</a></div><div class="nav-item"><a href="https://github.com/janker0718/ShareJava" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Github
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>设计模式</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/md/dev-spec/pattern/1_overview.html" aria-current="page" class="active sidebar-link">设计模式 - 概述</a></li><li><a href="/md/dev-spec/pattern/2_singleton.html" class="sidebar-link">设计模式 - 单例模式（Singleton Pattern）</a></li><li><a href="/md/dev-spec/pattern/3_factory.html" class="sidebar-link">设计模式 - 工厂模式（Factory Pattern）</a></li><li><a href="/md/dev-spec/pattern/4_abstract-factory.html" class="sidebar-link">设计模式 - 抽象工厂模式（Abstract Factory Pattern）</a></li></ul></section></li></ul> </aside> <div><main class="page"> <div class="theme-default-content content__default"><h1 id="设计模式-概述"><a href="#设计模式-概述" class="header-anchor">#</a> 设计模式 - 概述</h1> <h2 id="设计模式-简介"><a href="#设计模式-简介" class="header-anchor">#</a> 设计模式 - 简介</h2> <blockquote><p>设计模式（Design pattern）代表了最佳的实践，通常被有经验的面向对象的软件开发人员所采用。设计模式是软件开发人员在软件开发过程中面临的一般问题的解决方案。这些解决方案是众多软件开发人员经过相当长的一段时间的试验和错误总结出来的。</p></blockquote> <blockquote><p>设计模式是一套被反复使用的、多数人知晓的、经过分类编目的、代码设计经验的总结。使用设计模式是为了重用代码、让代码更容易被他人理解、保证代码可靠性。 毫无疑问，设计模式于己于他人于系统都是多赢的，设计模式使代码编制真正工程化，设计模式是软件工程的基石，如同大厦的一块块砖石一样。项目中合理地运用设计模式可以完美地解决很多问题，每种模式在现实中都有相应的原理来与之对应，每种模式都描述了一个在我们周围不断重复发生的问题，以及该问题的核心解决方案，这也是设计模式能被广泛应用的原因。</p></blockquote> <h2 id="设计模式-用途"><a href="#设计模式-用途" class="header-anchor">#</a> 设计模式 - 用途</h2> <p>设计模式在软件开发中的两个主要用途。</p> <h3 id="开发人员的共同平台"><a href="#开发人员的共同平台" class="header-anchor">#</a> 开发人员的共同平台</h3> <p>设计模式提供了一个标准的术语系统，且具体到特定的情景。例如，单例设计模式意味着使用单个对象，这样所有熟悉单例设计模式的开发人员都能使用单个对象，并且可以通过这种方式告诉对方，程序使用的是单例模式。</p> <h3 id="最佳的实践"><a href="#最佳的实践" class="header-anchor">#</a> 最佳的实践</h3> <p>设计模式已经经历了很长一段时间的发展，它们提供了软件开发过程中面临的一般问题的最佳解决方案。学习这些模式有助于经验不足的开发人员通过一种简单快捷的方式来学习软件设计。</p> <p>如果一个项目或工程比喻成一个人的话，代码如同肉体，设计模式就想是一个工程的灵魂。</p> <h2 id="设计模式-类型"><a href="#设计模式-类型" class="header-anchor">#</a> 设计模式 - 类型</h2> <p>根据设计模式的参考书 <code>Design Patterns</code> - <code>Elements of Reusable Object-Oriented Software</code>（中文译名：设计模式 - 可复用的面向对象软件元素） 中所提到的，总共有 23 种设计模式。这些模式可以分为三大类：创建型模式（<code>Creational Patterns</code>）、结构型模式（<code>Structural Patterns</code>）、行为型模式（<code>Behavioral Patterns</code>）。当然，我们还会讨论另一类设计模式：<code>J2EE</code> 设计模式。</p> <h3 id="创建型模式"><a href="#创建型模式" class="header-anchor">#</a> 创建型模式</h3> <blockquote><p>这些设计模式提供了一种在创建对象的同时隐藏创建逻辑的方式，而不是使用 new 运算符直接实例化对象。这使得程序在判断针对某个给定实例需要创建哪些对象时更加灵活。</p></blockquote> <ul><li>单例模式（<code>Singleton Pattern</code>）</li> <li>工厂模式（<code>Factory Pattern</code>）</li> <li>抽象工厂模式（<code>Abstract Factory Pattern</code>）</li> <li>建造者模式（<code>Builder Pattern</code>）</li> <li>原型模式（<code>Prototype Pattern</code>）</li></ul> <h3 id="结构型模式"><a href="#结构型模式" class="header-anchor">#</a> 结构型模式</h3> <blockquote><p>这些设计模式关注类和对象的组合。继承的概念被用来组合接口和定义组合对象获得新功能的方式。</p></blockquote> <ul><li>适配器模式（<code>Adapter Pattern</code>）</li> <li>桥接模式（<code>Bridge Pattern</code>）</li> <li>过滤器模式（<code>Filter、Criteria Pattern</code>）</li> <li>组合模式（<code>Composite Pattern</code>）</li> <li>装饰器模式（<code>Decorator Pattern</code>）</li> <li>外观模式（<code>Facade Pattern</code>）</li> <li>享元模式（<code>Flyweight Pattern</code>）</li> <li>代理模式（<code>Proxy Pattern</code>）</li></ul> <h3 id="行为型模式"><a href="#行为型模式" class="header-anchor">#</a> 行为型模式</h3> <blockquote><p>这些设计模式特别关注对象之间的通信。</p></blockquote> <ul><li>责任链模式（<code>Chain of Responsibility Pattern</code>）</li> <li>命令模式（<code>Command Pattern</code>）</li> <li>解释器模式（<code>Interpreter Pattern</code>）</li> <li>迭代器模式（<code>Iterator Pattern</code>）</li> <li>中介者模式（<code>Mediator Pattern</code>）</li> <li>备忘录模式（<code>Memento Pattern</code>）</li> <li>观察者模式（<code>Observer Pattern</code>）</li> <li>状态模式（<code>State Pattern</code>）</li> <li>空对象模式（<code>Null Object Pattern</code>）</li> <li>策略模式（<code>Strategy Pattern</code>）</li> <li>模板模式（<code>Template Pattern</code>）</li> <li>访问者模式（<code>Visitor Pattern</code>）</li></ul> <h3 id="j2ee-模式"><a href="#j2ee-模式" class="header-anchor">#</a> J2EE 模式</h3> <blockquote><p>这些设计模式特别关注表示层。这些模式是由 Sun Java Center 鉴定的。</p></blockquote> <ul><li>MVC 模式（<code>MVC Pattern</code>）</li> <li>业务代表模式（<code>Business Delegate Pattern</code>）</li> <li>组合实体模式（<code>Composite Entity Pattern</code>）</li> <li>数据访问对象模式（<code>Data Access Object Pattern</code>）</li> <li>前端控制器模式（<code>Front Controller Pattern</code>）</li> <li>拦截过滤器模式（<code>Intercepting Filter Pattern</code>）</li> <li>服务定位器模式（<code>Service Locator Pattern</code>）</li> <li>传输对象模式（<code>Transfer Object Pattern</code>）</li></ul> <p><strong>一张图描述一下设计模式之间的关系</strong></p> <p><img alt="" data-src="https://cdn.jsdelivr.net/gh/janker0718/image_store@master/img/20220329231739.png" loading="lazy" class="lazy"></p> <h2 id="设计模式的六大原则"><a href="#设计模式的六大原则" class="header-anchor">#</a> 设计模式的六大原则</h2> <ol><li><p>开闭原则（Open Close Principle）</p> <p>开闭原则的意思是：对扩展开放，对修改关闭。在程序需要进行拓展的时候，不能去修改原有的代码，实现一个热插拔的效果。简言之，是为了使程序的扩展性好，易于维护和升级。想要达到这样的效果，我们需要使用接口和抽象类，后面的具体设计中我们会提到这点。</p></li> <li><p>里氏代换原则（Liskov Substitution Principle）</p> <p>里氏代换原则是面向对象设计的基本原则之一。 里氏代换原则中说，任何基类可以出现的地方，子类一定可以出现。LSP 是继承复用的基石，只有当派生类可以替换掉基类，且软件单位的功能不受到影响时，基类才能真正被复用，而派生类也能够在基类的基础上增加新的行为。里氏代换原则是对开闭原则的补充。实现开闭原则的关键步骤就是抽象化，而基类与子类的继承关系就是抽象化的具体实现，所以里氏代换原则是对实现抽象化的具体步骤的规范。</p></li> <li><p>依赖倒转原则（Dependence Inversion Principle）</p> <p>这个原则是开闭原则的基础，具体内容：针对接口编程，依赖于抽象而不依赖于具体。</p></li> <li><p>接口隔离原则（Interface Segregation Principle）</p> <p>这个原则的意思是：使用多个隔离的接口，比使用单个接口要好。它还有另外一个意思是：降低类之间的耦合度。由此可见，其实设计模式就是从大型软件架构出发、便于升级和维护的软件设计思想，它强调降低依赖，降低耦合。</p></li> <li><p>迪米特法则，又称最少知道原则（Demeter Principle）</p> <p>最少知道原则是指：一个实体应当尽量少地与其他实体之间发生相互作用，使得系统功能模块相对独立。</p></li> <li><p>合成复用原则（Composite Reuse Principle）</p> <p>合成复用原则是指：尽量使用合成/聚合的方式，而不是使用继承。</p></li></ol></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/janker0718/ShareJava/edit/master/docs/md/dev-spec/pattern/1_overview.md" target="_blank" rel="noopener noreferrer">在 GitHub 上编辑此页</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新: </span> <span class="time">3/30/2022,</span></div></footer> <div class="page-nav"><p class="inner"><!----> <span class="next"><a href="/md/dev-spec/pattern/2_singleton.html">
          设计模式 - 单例模式（Singleton Pattern）
        </a>
        →
      </span></p></div> </main></div> <aside class="page-sidebar"> <div class="page-side-toolbar"><div class="option-box-toc-fixed"><div class="toc-container-sidebar"><div class="pos-box"><div class="icon-arrow"></div> <div class="scroll-box" style="max-height:650px"><div style="font-weight:bold;text-align:center;">设计模式 - 概述</div> <hr> <div class="toc-box"><ul class="toc-sidebar-links"><li><a href="/md/dev-spec/pattern/1_overview.html#设计模式-简介" class="toc-sidebar-link">设计模式 - 简介</a><ul class="toc-sidebar-sub-headers"></ul></li><li><a href="/md/dev-spec/pattern/1_overview.html#设计模式-用途" class="toc-sidebar-link">设计模式 - 用途</a><ul class="toc-sidebar-sub-headers"><li class="toc-sidebar-sub-header"><a href="/md/dev-spec/pattern/1_overview.html#开发人员的共同平台" class="toc-sidebar-link">开发人员的共同平台</a></li><li class="toc-sidebar-sub-header"><a href="/md/dev-spec/pattern/1_overview.html#最佳的实践" class="toc-sidebar-link">最佳的实践</a></li></ul></li><li><a href="/md/dev-spec/pattern/1_overview.html#设计模式-类型" class="toc-sidebar-link">设计模式 - 类型</a><ul class="toc-sidebar-sub-headers"><li class="toc-sidebar-sub-header"><a href="/md/dev-spec/pattern/1_overview.html#创建型模式" class="toc-sidebar-link">创建型模式</a></li><li class="toc-sidebar-sub-header"><a href="/md/dev-spec/pattern/1_overview.html#结构型模式" class="toc-sidebar-link">结构型模式</a></li><li class="toc-sidebar-sub-header"><a href="/md/dev-spec/pattern/1_overview.html#行为型模式" class="toc-sidebar-link">行为型模式</a></li><li class="toc-sidebar-sub-header"><a href="/md/dev-spec/pattern/1_overview.html#j2ee-模式" class="toc-sidebar-link">J2EE 模式</a></li></ul></li><li><a href="/md/dev-spec/pattern/1_overview.html#设计模式的六大原则" class="toc-sidebar-link">设计模式的六大原则</a><ul class="toc-sidebar-sub-headers"></ul></li></ul></div></div></div></div></div> <div class="option-box"><a title="点击切换全屏" style="text-align:center;padding-left:2px;"><img src="/images/system/full.png" width="30px" class="nozoom"> <span style="color:gray;font-size:11px;font-weight:400;">全屏看</span></a></div> <div class="option-box-toc-over"><img src="/images/system/mulu.png" class="nozoom"> <span class="show-txt">目录</span> <div class="toc-container"><div class="pos-box"><div class="icon-arrow"></div> <div class="scroll-box" style="max-height:550px"><div style="font-weight:bold;text-align:center;">设计模式 - 概述</div> <hr> <div class="toc-box"><ul class="toc-sidebar-links"><li><a href="/md/dev-spec/pattern/1_overview.html#设计模式-简介" class="toc-sidebar-link">设计模式 - 简介</a><ul class="toc-sidebar-sub-headers"></ul></li><li><a href="/md/dev-spec/pattern/1_overview.html#设计模式-用途" class="toc-sidebar-link">设计模式 - 用途</a><ul class="toc-sidebar-sub-headers"><li class="toc-sidebar-sub-header"><a href="/md/dev-spec/pattern/1_overview.html#开发人员的共同平台" class="toc-sidebar-link">开发人员的共同平台</a></li><li class="toc-sidebar-sub-header"><a href="/md/dev-spec/pattern/1_overview.html#最佳的实践" class="toc-sidebar-link">最佳的实践</a></li></ul></li><li><a href="/md/dev-spec/pattern/1_overview.html#设计模式-类型" class="toc-sidebar-link">设计模式 - 类型</a><ul class="toc-sidebar-sub-headers"><li class="toc-sidebar-sub-header"><a href="/md/dev-spec/pattern/1_overview.html#创建型模式" class="toc-sidebar-link">创建型模式</a></li><li class="toc-sidebar-sub-header"><a href="/md/dev-spec/pattern/1_overview.html#结构型模式" class="toc-sidebar-link">结构型模式</a></li><li class="toc-sidebar-sub-header"><a href="/md/dev-spec/pattern/1_overview.html#行为型模式" class="toc-sidebar-link">行为型模式</a></li><li class="toc-sidebar-sub-header"><a href="/md/dev-spec/pattern/1_overview.html#j2ee-模式" class="toc-sidebar-link">J2EE 模式</a></li></ul></li><li><a href="/md/dev-spec/pattern/1_overview.html#设计模式的六大原则" class="toc-sidebar-link">设计模式的六大原则</a><ul class="toc-sidebar-sub-headers"></ul></li></ul></div></div></div></div></div> <div class="option-box"><img src="/images/system/wechat.png" class="nozoom"> <span class="show-txt">手机看</span> <div class="toc-container"><div class="pos-box"><div class="icon-arrow"></div> <div class="scroll-box" style="text-align:center"><span style="font-size:0.9rem">微信扫一扫</span> <img height="180px" src="https://api.qrserver.com/v1/create-qr-code/?data=https://www.share-java.com/md/dev-spec/pattern/1_overview.html" style="margin:10px;">
                可以<b>手机看</b>或分享至<b>朋友圈</b></div></div></div></div> <div class="option-box"><img src="/images/system/toggle.png" width="30px" class="nozoom"> <span class="show-txt">左栏</span></div> <div class="option-box"><img src="/images/system/download-2.png" width="25px" class="nozoom"> <span class="show-txt">下资料</span> <div class="toc-container"><div class="pos-box"><div class="icon-arrow"></div> <div class="scroll-box" style="text-align:center"><span style="font-size:0.8rem;font-weight:bold;">扫描公众号，回复<span style="color:red;">“66”</span>下载<span style="color:red;">1TB+</span>学习技术资料、PDF书籍、简历模板「无任何套路」</span> <img src="https://cdn.jsdelivr.net/gh/janker0718/image_store/img/20220103214503494.png" height="180px" style="margin:10px;"> <b>公众号:</b> 爪哇干货分享
              </div></div></div></div> <!----> <div title="设计模式 - 单例模式（Singleton Pattern）" class="option-box" style="padding-left:2px;text-align:center;"><a href="/md/dev-spec/pattern/2_singleton.html"><img src="/images/system/next2.png" width="30px" class="nozoom"> <span class="show-txt">下一篇</span></a></div></div>  <div class="page-side-sitemap"><div class="option-box"><img src="/images/system/sitemap.png" class="nozoom img"> <span class="show-txt">站点图</span> <div class="sitemap-container"><h4>站点导航图
              <a href="/md/about/me/about-me.html" class="sitemap-top-link"> 关于我</a> <a href="/md/about/me/about-arch.html" class="sitemap-top-link"> 关于学习</a></h4> <table class="sitemap-table"><tr><td nowrap="nowrap"><div class="sitemap-col-group">常用搜索</div></td> <td><div class="sitemap-col-item"><a href="http://www.baidu.com/" target="_blank" title="百度">  
          百度
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="sitemap-col-item"><a href="http://www.google.com/" target="_blank" title="Google">  
          Google
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="sitemap-col-item"><a href="http://www.bing.com/" target="_blank" title="Bing">  
          Bing
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="sitemap-col-item"><a href="https://github.com" target="_blank" title="Github">  
          Github
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="sitemap-col-item"><a href="https://www.programcreek.com/java-api-examples/index.php" target="_blank" title="搜代码">  
          搜代码
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></td> <!----></tr><tr><td nowrap="nowrap"><div class="sitemap-col-group">技术社区</div></td> <td><div class="sitemap-col-item"><a href="http://www.csdn.net/" target="_blank" title="CDSN">  
          CDSN
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="sitemap-col-item"><a href="http://www.cnblogs.com/" target="_blank" title="博客园">  
          博客园
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="sitemap-col-item"><a href="https://www.oschina.net" target="_blank" title="OSChina">  
          OSChina
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="sitemap-col-item"><a href="https://segmentfault.com/" target="_blank" title="思否">  
          思否
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="sitemap-col-item"><a href="https://juejin.im" target="_blank" title="掘金">  
          掘金
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="sitemap-col-item"><a href="https://www.linuxidc.com/" target="_blank" title="Linux公社">  
          Linux公社
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="sitemap-col-item"><a href="https://www.ibm.com/developerworks/cn/" target="_blank" title="IBM 开发者">  
          IBM 开发者
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div><div class="sitemap-col-item"><a href="https://stackoverflow.com" target="_blank" title="StackOverflow">  
          StackOverflow
          <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></td> <!----></tr></table></div></div></div> <!----> </aside></div><div class="global-ui"><div class="read-more-wrap" style="display:none;position:absolute;bottom:0px;z-index:9999;width:100%;margin-top:-100px;font-family:PingFangSC-Regular, sans-serif;"><div id="read-more-mask" style="position: relative; height: 200px; background: -webkit-gradient(linear, 0 0%, 0 100%, from(rgba(255, 255, 255, 0)), to(rgb(255, 255, 255)));"></div> <a id="read-more-btn" target="_self" style="position: absolute; left: 50%; top: 70%; bottom: 30px; transform: translate(-50%, -50%); width: 160px; height: 36px; line-height: 36px; font-size: 15px; text-align: center; border: 1px solid rgb(222, 104, 109); color: rgb(222, 104, 109); background: rgb(255, 255, 255); cursor: pointer; border-radius: 6px;">阅读全文</a> <div id="btw-modal-wrap" style="display: none;"><div id="btw-mask" style="position: fixed; top: 0px; right: 0px; bottom: 0px; left: 0px; opacity: 0.7; z-index: 999; background: rgb(0, 0, 0);"></div> <div id="btw-modal" style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 300px; text-align: center; font-size: 13px; background: rgb(255, 255, 255); border-radius: 10px; z-index: 9999; font-family: PingFangSC-Regular, sans-serif;"><span id="btw-modal-close-btn" style="position: absolute; top: 5px; right: 15px; line-height: 34px; font-size: 34px; cursor: pointer; opacity: 0.2; z-index: 9999; color: rgb(0, 0, 0); background: none; border: none; outline: none;">×</span> <p id="btw-modal-header" style="margin-top: 40px; line-height: 1.8; font-size: 13px;">
                扫码或搜索：<span style="color: #E9405A; font-weight: bold;">爪哇干货分享</span> <br>发送：<span id="fustack-token" class="token" style="color: #e9415a; font-weight: bold; font-size: 17px; margin-bottom: 45px;">10086</span> <br>即可<span style="color: #e9415a; font-weight: bold;">立即永久</span>解锁本站全部文章</p> <img src="/images/personal/qrcode.png" style="width: 180px; margin-top: 10px; margin-bottom: 30px; border: 8px solid rgb(230, 230, 230);"></div></div></div><div class="pay-read-more-wrap" style="display:none;position:absolute;bottom:0px;z-index:9999;width:100%;margin-top:-100px;font-family:PingFangSC-Regular, sans-serif;"><div id="pay-read-more-mask" style="position: relative; height: 200px; background: -webkit-gradient(linear, 0 0%, 0 100%, from(rgba(255, 255, 255, 0)), to(rgb(255, 255, 255)));"></div> <a id="pay-read-more-btn" target="_blank" style="position: absolute; left: 50%; top: 70%; bottom: 30px; transform: translate(-50%, -50%); width: 160px; height: 36px; line-height: 36px; font-size: 15px; text-align: center; border: 1px solid rgb(222, 104, 109); color: rgb(222, 104, 109); background: rgb(255, 255, 255); cursor: pointer; border-radius: 6px;">付费阅读</a></div><!----><div></div></div></div>
    <script src="/assets/js/cg-styles.js?v=1648640762568" defer></script><script src="/assets/js/cg-4.js?v=1648640762568" defer></script><script src="/assets/js/cg-3.js?v=1648640762568" defer></script><script src="/assets/js/cg-18.js?v=1648640762568" defer></script><script src="/assets/js/cg-5.js?v=1648640762568" defer></script><script src="/assets/js/cg-6.js?v=1648640762568" defer></script><script src="/assets/js/cg-app.js?v=1648640762568" defer></script>
  </body>
</html>
